<?php
/**
 * User: xuhong
 * Date: 2018/10/30
 */

namespace extend\wechat\mp;


class Templet
{
    /**
     * 发送模版
     * @param $template_body
     * @return mixed
     */
    public static function sendTemplate($template_body)
    {
        $access_token = Voucher::accessToken()['access_token'];
        $url = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token={$access_token}";

        $data = json_encode($template_body, JSON_UNESCAPED_UNICODE);
        return postRequest($url, $data);
    }


    /**
     * 删除模版
     * @param $template_id
     * @return mixed
     */
    public static function deleteTemplate( $template_id)
    {
        $access_token = Voucher::accessToken()['access_token'];
        $url = "https://api.weixin.qq.com/cgi-bin/template/del_private_template?access_token={$access_token}";

        $data["template_id"] = $template_id;
        $data = json_encode($data, JSON_UNESCAPED_UNICODE);
        return postRequest($url, $data);
    }
}